/*
 * @Date: 2025-06-16 10:09:31
 * @LastEditors: lyx
 * @LastEditTime: 2025-06-16 10:09:40
 * @FilePath: \blog\src\pages\robots.txt.ts
 * @Description: 
 */
import type { APIRoute } from "astro";

const getRobotsTxt = (sitemapURL: URL) => `
User-agent: *
Allow: /
Sitemap: ${sitemapURL.href}
`;

export const GET: APIRoute = ({ site }) => {
  const sitemapURL = new URL("sitemap-index.xml", site);
  return new Response(getRobotsTxt(sitemapURL));
};
